<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
	<% String path=request.getContextPath(); String basePath=request.getScheme() + "://" + request.getServerName() + ":"
		+ request.getServerPort() + path + "/" ; %>

		<!DOCTYPE html>
		<html>

		<head>
			<base href="<%=basePath%>">

			<title></title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

		</head>

		<body>
			<%@ include file="/WEB-INF/jsp/common/header.jsp" %>
				<%@ include file="/WEB-INF/jsp/common/loadDiv.jsp" %>

					<script type="text/javascript">
						$(function () {
							$('#startTime').datebox('setValue', getBeforeCurrentDate30Days());
							$('#endTime').datebox('setValue', getNowFormatDate());
							bindgrid();
						});
					</script>
					<script>
						function del(node) {
							$.ajax({
								type: "delete",
								url: 'qm/oos/item/delete?' + 'itemId=' + itemId,
								//                dataType: "xml",				
								success: function (data) {
									$.messager.alert('消息', data.msg);
									$('#add').window('close');
									bindgrid();
								},
								error: function (XMLHttpRequest, textStatus, errorThrown) {
									$.messager.alert('消息', errorThrown);
								}
							});
						}

						function save() {
							if (!$('#fm').form('validate')) {
								return;
							}
							var model = {
								itemId: $('#itemId').textbox('getValue'),
								osId: $('#osId').textbox('getValue'),
								itemName: $('#itemName').textbox('getValue'),
								itemExceptionDescr: $('#itemExceptionDescr').textbox('getValue'),
								progress: $('#progress').textbox('getValue'),
								status: $('#status').textbox('getValue'),
								createTime: $('#createTime').textbox('getValue'),
								createId: $('#createId').textbox('getValue'),
								createName: $('#createName').textbox('getValue'),
								updateTime: $('#updateTime').textbox('getValue'),
								updateId: $('#updateId').textbox('getValue'),
								updateName: $('#updateName').textbox('getValue'),
								delFlag: $('#delFlag').textbox('getValue'),
								remark: $('#remark').textbox('getValue')
							};
							$.ajax({
								type: "post",
								dataType: "json",
								url: 'qm/oos/item/save',
								data: JSON.stringify(model),
								contentType: "application/json",
								success: function (data) {
									if (data.code != 60200) {
										$.messager.alert('消息', data.msg);
									} else {
										$.messager.alert('消息', data.msg);
										let dg = $('#dg');
										dg.datagrid('enableFilter');
										dg.datagrid('load');
										$('#add').window('close');
									}
								},
								error: function (XMLHttpRequest, textStatus, errorThrown) {
									$.messager.alert('消息', errorThrown);
								}
							})

						}

						function editrow() {
							//编辑用户
							var row = $('#dg').datagrid('getSelected');
							if (row) {
								$('#add').window('open');
								$('#fm').form('load', row);

							} else {
								$.messager.alert('消息', '请选中一条数据');
							}
						}
					</script>
					<script>
						/**
														 *  按条件查询报价列表
														 */
						function selectList() {
							var startTime = $('#startTime').datebox('getValue')
							var endTime = $('#endTime').datebox('getValue')
							var status = $('#status').combobox('getValue');
							var dg = $('#dg');
							dg.datagrid('enableFilter');
							dg.datagrid('load', {
								startTime: startTime ? startTime : '',
								endTime: endTime ? endTime : '',
								status: status ? status : ''
							});
						}

						function bindgrid() {
							var startTime = $('#startTime').datebox('getValue')
							var endTime = $('#endTime').datebox('getValue')
							var status = $('#status').combobox('getValue');
							$('#dg').datagrid(
								{
									title: '',
									queryParams: {
										startTime: startTime,
										endTime: endTime,
										status: status
									},
									url: "qm/oos/item/selectList",
									iconCls: 'icon-application',
									width: getWidth(0.98),
									height: 400,
									nowrap: true,
									filterDelay: 0,
									rownumbers: true,
									animate: false,
									collapsible: false,
									clientPaging: false,
									remoteFilter: true,
									singleSelect: true,
									pagination: true,
									remoteSort: true,
									frozenColumns: [[]],
									columns: [[{
										field: 'itemId',
										title: '分析项id',
										sortable: true,
										hidden: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'osId',
										title: 'OOSID',
										sortable: true,
										hidden: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'itemName',
										title: '分析项名称',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'itemExceptionDescr',
										title: '异常情况',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'progress',
										title: '进度',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'status',
										title: '状态',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'createTime',
										title: '创建时间',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'createId',
										title: '创建人id',
										sortable: true,
										hidden: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'createName',
										title: '创建人名称',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'updateTime',
										title: '更新时间',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'updateId',
										title: '更新人id',
										sortable: true,
										hidden: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'updateName',
										title: '更新人名称',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'delFlag',
										title: '删除标识',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'remark',
										title: '备注',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}]],
									toolbar: [{
										text: '增加',
										iconCls: 'icon-add',
										handler: function () {
											$('#fm').form('clear');
											$('#add').window('open');
										}
									},
										'-',
									{
										text: '编辑',
										iconCls: 'icon-edit',
										handler: function () {
											editrow()
										}
									},
										'-',
									{
										text: '删除',
										iconCls: 'icon-cancel',
										handler: function () {
											var row = $('#dg').datagrid(
												'getSelected');
											if (row) {
												$.messager.confirm('提示', '确定要删除这个吗?', function (r) {
													if (r) { del(row); }
												});
											}
										}
									}],
									onLoadSuccess: function () {
									},
									onDblClickRow: function () {
										editrow();
									}
								});
							$('#dg').datagrid('enableFilter');
						} 
					</script>
					<style scoped="scoped">
						.textbox {
							height: 20px;
							margin: 0;
							padding: 0 2px;
							box-sizing: content-box;
						}

						/*.table tr {
        height: 15px;
    }*/
					</style>
					<div class="query_criteria" id="query_criteria">
						<div style="margin: 5px 0px">
							<%-- 搜索框 --%>
								<label style="font-size: 12px;">创建时间：</label> <input class="easyui-datebox"
									name="startTime" id="startTime"
									data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
									value="" style="width: 150px"> <label style="font-size: 10px;">~</label> <input
									class="easyui-datebox" name="endTime" id="endTime"
									data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
									style="width: 150px" /> <label
									style="margin-left: 20px; font-size: 12px;">状态：</label>
								<input class="easyui-combobox" id="status" name="status" style="width: 80px;"
									data-options="valueField: 'value',editable:false,
						textField: 'label',panelHeight:'auto',data: [{
							label: '全部',
							value: ''
						},{
							label: '待提交',
							value: '0',
							selected:true
						},{
							label: '已提交',
							value: '1'
						}]">
								</select> <a id="search" style="margin-left: 30px" href="javascript:void(0)"
									class="easyui-linkbutton" data-options="iconCls:'icon-search'"
									onclick="selectList()">查询</a>
						</div>

						<table id="dg"></table>

						<div id="add" class="easyui-window" closed="true" modal="true" title="用户信息"
							style="width: 500px; height: 450px; padding: 10px 20px">
							<form id="fm" class="ssec-form">
								<table class="table">
									<tr>
										<td>
											<div class="ssec-label">分析项id：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="itemId" name="itemId" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">OOSID：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="osId" name="osId" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">分析项名称：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="itemName" name="itemName" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">异常情况：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="itemExceptionDescr" name="itemExceptionDescr"
													class="easyui-textbox" data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">进度：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="progress" name="progress" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">状态：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="status" name="status" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">创建时间：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="createTime" name="createTime" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">创建人id：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="createId" name="createId" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">创建人名称：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="createName" name="createName" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">更新时间：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="updateTime" name="updateTime" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">更新人id：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="updateId" name="updateId" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">更新人名称：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="updateName" name="updateName" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">删除标识：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="delFlag" name="delFlag" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
									<tr>
										<td>
											<div class="ssec-label">备注：</div>
										</td>
										<td>
											<div class="ssec-text normal">
												<input id="remark" name="remark" class="easyui-textbox"
													data-options="required:true" />
											</div>
										</td>
									</tr>
								</table>
								<div style="padding: 5px; text-align: right;">
									<a class="easyui-linkbutton" onclick="save();" iconcls="icon-save">保存</a>
								</div>
							</form>
						</div>
					</div>
		</body>

		</html>